/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.demo.repository.entity;

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import com.gitee.peigenlpy.sansheng.core.annotation.ColumnField;
import info.peigen.hotpot.business.account.facade.enums.AccountDirection;
import info.peigen.hotpot.business.account.facade.enums.AccountTransCode;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.lang.money.Money;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.handler.MoneyBeetlSqlHandler;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

import java.util.Date;

/**
 * <b>(AccountLogEntity)</b>
 * 账户流水记录表
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/1
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "account_log", comment = "账户流水记录表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "account_log")
public class AccountLogEntity extends AbstractCreateTimeEntity {
    @ColumnField(change = false)
    @Column(name = "account_log_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "账户流水记录Id")
    @Unique(value = "accountLogId", columns = "account_log_id")
    @org.beetl.sql.annotation.entity.Column("account_log_id")
    String           accountLogId;
    @ColumnField(change = false)
    @Column(name = "trans_log_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "账户交易流水记录Id")
    @Index(value = "transLogId", columns = "trans_log_id")
    @org.beetl.sql.annotation.entity.Column("trans_log_id")
    String           transLogId;
    @ColumnField(change = false)
    @Column(name = "trade_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "交易Id")
    @Index(value = "tradeId", columns = "trade_id")
    @org.beetl.sql.annotation.entity.Column("trade_id")
    String           tradeId;
    @Column(name = "trans_code", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "交易代码")
    @Index(value = "transCode", columns = "trans_code")
    @org.beetl.sql.annotation.entity.Column("trans_code")
    AccountTransCode transCode;
    @Column(name = "account_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "账户Id")
    @Index(value = "accountId", columns = "account_id")
    @org.beetl.sql.annotation.entity.Column("account_id")
    String           accountId;
    @ColumnField(change = false)
    @Column(name = "balance", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "账户期初余额")
    @org.beetl.sql.annotation.entity.Column("balance")
    @MoneyBeetlSqlHandler
    Money            balance;
    @Column(name = "balance_currency", type = MySqlTypeConstant.VARCHAR, length = 3, comment = "账户期初余额币种")
    @org.beetl.sql.annotation.entity.Column("balance_currency")
    Currency         balanceCurrency;
    @ColumnField(change = false)
    @Column(name = "trans_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "交易金额")
    @org.beetl.sql.annotation.entity.Column("trans_amount")
    @MoneyBeetlSqlHandler
    Money            transAmount;
    @Column(name = "trans_amount_currency", type = MySqlTypeConstant.VARCHAR, length = 3, comment = "交易金额币种")
    @org.beetl.sql.annotation.entity.Column("trans_amount_currency")
    Currency         transAmountCurrency;
    @Column(name = "direction", type = MySqlTypeConstant.VARCHAR, length = 10, comment = "借贷方向;Debit借记,Credit贷记")
    @Index(value = "direction", columns = "direction")
    @org.beetl.sql.annotation.entity.Column("direction")
    AccountDirection direction;
    @Column(name = "trans_time", type = MySqlTypeConstant.VARCHAR, length = 40, comment = "交易时间")
    @Index(value = "transTime", columns = "trans_time")
    @org.beetl.sql.annotation.entity.Column("trans_time")
    Date             transTime;
    @Column(name = "settle_time", type = MySqlTypeConstant.VARCHAR, length = 40, comment = "清算时间;有别与交易时间,应是实际资金清算系统提供的交易完成时间,视为清算时间")
    @Index(value = "settleTime", columns = "settle_time")
    @org.beetl.sql.annotation.entity.Column("settle_time")
    Date             settleTime;
    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 200, comment = "备注")
    @org.beetl.sql.annotation.entity.Column("memo")
    String           memo;
}